//
//  HAODE
//
//  Created by panquanReabam.com on 15/9/23.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "ServiceConfirmViewController.h"
#import "ZJSwitch.h"
#import "HAODEsingleton.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "UIImageView+WebCache.h"
#import "daogouview.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "ConfirmCell.h"
#import "huiyuandengjiViewController.h"
#import "shangpingview.h"
#import "peisongleibieViewController.h"
#import "ToResiduePayViewController.h"
#import "huiyuanDetailsViewController.h"
@interface ServiceConfirmViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate,UISearchBarDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) NSString *areaValue;
@property (strong, nonatomic) NSString*cityValue;
@property (strong, nonatomic) NSString*GuideCode;
@property (strong, nonatomic) NSString*memberId;
@property (strong, nonatomic) NSString*isEarnest;
@property(nonatomic,retain)UIDatePicker* da;
@end

@implementation ServiceConfirmViewController

{
    UISearchBar *search;
    HAODEsingleton* commdity;
    UIButton* sxBtn;
    UIButton*jiantouBtn;
    UIButton*cardBtn;
    float lastContentOffset;
    UITextField*searchTextField;
    UITextField*zhekoujineTextFied;
    UITextField*songhuoTextFied;
    UITextField*anzhuangTextFied;
    UIButton*daogouname;
    UIView*view1;
    shangpingview*shangpingView;
    UIScrollView*mainScroll;
    UIScrollView*MYmainScroll;
    UILabel*huiyuanname;
    UIButton *tureBtn;
    UILabel*dingdanhao1;
    BOOL saveAccount;
    BOOL isHaveDian;
    UIButton *xuanze;
    UIButton*jiagemingxi1;
    UIButton*DiscountRateSatBtn;
    NSMutableArray* arrrss;
    NSMutableArray*DiscountRatecode ;
    NSMutableArray*DiscountRatecontent ;
    ZJSwitch *switch2;
    UITextField*dinjinjineTextFied;
    UIButton*EarnestRateSatBtn;
    UILabel* weightke;
    UIView*view2;
    UIView*view3;
    UIView*view4;
    UIView*view5;
    UIView*view6;
    UITextView* tv;
    UILabel * label;
    UIImageView*imagess;
    UILabel*shengyuzhifujiage1;
    UIButton*anzhuangSatBtn;
    UIButton*peisongSatBtn;
    UIButton*jiantouBtn1;
    UIButton*jiantouBtn2;
    UIButton*jiantouBtn3;
    UIButton*jiantouBtn4;
    UIButton*jiantouBtn5;
    UIButton*jiantouBtn6;
    UIView* myToolBar;
    NSString*totalMoney;
    UILabel*youhuijine;
    UILabel*youhuiquanjine;
    UIButton*hejiMoney;
    UIView*beizhuView;
    UITextField*xianjinTextFied;
    UIView*diview;
    UIView*footerview;
    
    UIView*footview;
    UIButton*xiugaiview;
    UILabel*shu;
    UITextField*jiageTextFied;
    UIView*toumingtu;
    UIButton*zhangkai;
    
      NSMutableArray*keyiquantity;
    NSMutableArray*quantity;
    NSMutableArray *selectFeatureCodeArray;
    NSMutableArray *orderItemIds;
    NSMutableArray *selectimageArray;
    NSMutableArray *selectshuliangArray;
    NSMutableArray *selectduoshaoArray;
    NSMutableArray *selectitemCodeArray;
    NSMutableArray *selectguigeArray;
    NSMutableArray *selectName;
    UITableView*table;

}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    

    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    
    
    
}



- (void)viewDidLoad
{
    
    [super viewDidLoad];
    commdity=[HAODEsingleton shared];
    
    self.title=@"售后确认";
    

    selectFeatureCodeArray=[[NSMutableArray alloc] init];
    selectimageArray=[[NSMutableArray alloc] init];
    selectshuliangArray=[[NSMutableArray alloc] init];
    selectduoshaoArray=[[NSMutableArray alloc] init];
    selectName=[[NSMutableArray alloc] init];
    orderItemIds=[[NSMutableArray alloc] init];
    selectguigeArray=[[NSMutableArray alloc] init];
    quantity= [[NSMutableArray alloc] init];
    keyiquantity= [[NSMutableArray alloc] init];
    
    table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    table.delegate = self;
    table.dataSource = self;
    table.separatorStyle=UITableViewCellSeparatorStyleNone;
    
    
    [self.view addSubview:table];

    
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    MYmainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight)];
    [MYmainScroll setBackgroundColor: zuiqianhuicolor];
    
    MYmainScroll.delegate = self;
    MYmainScroll.userInteractionEnabled = YES;
    MYmainScroll.scrollEnabled = YES;
    MYmainScroll.showsVerticalScrollIndicator = FALSE;
    MYmainScroll.showsHorizontalScrollIndicator = FALSE;
    
    view6=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 80/2)];
    view6.backgroundColor=[UIColor whiteColor];
    [MYmainScroll addSubview:view6];
    UIView* disev=[[UIView alloc]initWithFrame:CGRectMake(0, 40, ScreenWidth, 10)];
    disev.backgroundColor=zuiqianhuicolor;
    [MYmainScroll addSubview:disev];
    UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, 40, ScreenWidth, 0.35)];
    line1.backgroundColor=qianhuicolor;
    [MYmainScroll addSubview:line1];
    UILabel *line2=[[UILabel alloc] initWithFrame:CGRectMake(0, 40+10-0.35, ScreenWidth, 0.35)];
    line2.backgroundColor=qianhuicolor;
    [MYmainScroll addSubview:line2];
    UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 25/2, 40, 15)];
    duogou.text=[NSString stringWithFormat:@"员工"];
    duogou.textColor=zhonghuiColor;
    duogou.font=[UIFont systemFontOfSize:15];
    [MYmainScroll addSubview:duogou];
    
    
        NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
        NSString* UserName = [user1 objectForKey:@"userName"];
        self.GuideCode = [user1 objectForKey:@"UserCode"];
        daogouname=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-200,  25/2,180,15)];
        [daogouname setTitle:UserName forState:UIControlStateNormal];
        daogouname.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        daogouname.titleLabel.textAlignment=NSTextAlignmentRight;
        daogouname.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        //[daogouname addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [daogouname setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [MYmainScroll addSubview:daogouname];
    

    
    
    sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0, ScreenWidth*40/750, ScreenWidth*40/750)];
    [sxBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    //  [sxBtn addTarget:self action:@selector(addhuiyuan:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
    self.navigationItem.rightBarButtonItem = myBtnBtn;
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:commdity. orderId forKey:@"serviceId"];
    
    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"Business/Service/ToConfirm" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                
                commdity.noId=[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceNo"]];
                
                
                view1=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 70)];
                view1.backgroundColor=[UIColor whiteColor];
                [MYmainScroll addSubview:view1];
                NSString *s12 = [NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceNo"]];
                UIFont *font12 = [UIFont systemFontOfSize:17];
                CGSize size12 = CGSizeMake(320, 2000);
                CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
                UILabel*source=[[UILabel alloc]initWithFrame:CGRectMake(15, 32/2, labelsize12.width, 17)];
                source.text=[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceNo"]];
                source.textColor=[UIColor blackColor];
                source.font=[UIFont systemFontOfSize:17];
                [view1 addSubview:source];
                
                
                
                UILabel*deliveryStatus=[[UILabel alloc]initWithFrame:CGRectMake(source.right+11, 37/2, 60, Statusfot)];
//                deliveryStatus.textAlignment=NSTextAlignmentCenter;
                if ([[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceStatus"]] isEqualToString:@"A"]) {
                    deliveryStatus.textColor=luseColor;
                    deliveryStatus.text=[NSString stringWithFormat:@"%@",  @"服务申请"];
                }if ([[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceStatus"]] isEqualToString:@"R"]) {
                    deliveryStatus.textColor=luseColor;
                    deliveryStatus.text=[NSString stringWithFormat:@"%@",  @"服务登记"];
                }
                if ([[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceStatus"]] isEqualToString:@"C"]) {
                    deliveryStatus.textColor=luseColor;
                    deliveryStatus.text=[NSString stringWithFormat:@"%@",  @"服务确认"];
                }
                
                deliveryStatus.font=[UIFont systemFontOfSize:Statusfot];
                [view1 addSubview:deliveryStatus];
                
                
                UILabel*orderStatus=[[UILabel alloc]initWithFrame:CGRectMake(deliveryStatus.right, 37/2, 140, Statusfot)];
//                orderStatus.textAlignment=NSTextAlignmentCenter;
                orderStatus.textColor=shenhongsecolor;
                orderStatus.text=[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceTypeName"]];
                
                orderStatus.font=[UIFont systemFontOfSize:Statusfot];
                [view1 addSubview:orderStatus];

                
                UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 85/2, 30, contenfot)];
                duogou.text=[NSString stringWithFormat:@"来源"];
                duogou.textColor=zhonghuiColor;
                duogou.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:duogou];
                
                NSString *s1 = [NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"source"]];
                UIFont *font1 = [UIFont systemFontOfSize:contenfot];
                CGSize size1 = CGSizeMake(320, 2000);
                CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
                
                daogouname=[[UIButton alloc]initWithFrame:CGRectMake(duogou.right,  85/2,labelsize1.width+5,15)];
                [daogouname setTitle:[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"source"]] forState:UIControlStateNormal];
                daogouname.titleLabel.font=[UIFont systemFontOfSize:contenfot];
                daogouname.titleLabel.textAlignment=NSTextAlignmentLeft;
                daogouname.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
                [daogouname setTitleColor:shenhuicolor forState:UIControlStateNormal];
                [view1 addSubview:daogouname];
                
                
                UILabel* orderDate=[[UILabel alloc]initWithFrame:CGRectMake(daogouname.right+10, 85/2, 65, 15)];
                orderDate.text=@"下单日期";
                orderDate.textColor=zhonghuiColor;
                orderDate.font=[UIFont systemFontOfSize:contenfot];
//                [view1 addSubview:orderDate];
                NSRange range={0,10};
                NSString* string =[[[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"serviceDate"] substringWithRange:range];
                UILabel* orderDate1=[[UILabel alloc]initWithFrame:CGRectMake(daogouname.right+10, 85/2, 180, 15)];
                orderDate1.text=[NSString stringWithFormat:@"%@",  string];
                orderDate1.textColor=shenhuicolor;
                orderDate1.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:orderDate1];
                UILabel *line911=[[UILabel alloc] initWithFrame:CGRectMake(0, 70, ScreenWidth, 0.35)];
                line911.backgroundColor=qianhuicolor;
                [view1 addSubview:line911];
                UILabel *line91=[[UILabel alloc] initWithFrame:CGRectMake(0, 80, ScreenWidth, 0.35)];
                line91.backgroundColor=qianhuicolor;
                [view1 addSubview:line91];
                
                
                
                
                view2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+10, ScreenWidth, 70)];
                view2.backgroundColor=[UIColor whiteColor];
                view2.layer.borderWidth=0.35;
                view2.layer.borderColor=qianhuicolor.CGColor;
                [MYmainScroll addSubview:view2];
                UIButton*jiantou = [[UIButton alloc]init];
                jiantou.frame = CGRectMake(ScreenWidth-30,70/2-7,8, 13);
                [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
                [jiantou addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
                [view2 addSubview:jiantou];
                UIButton*suobtn=[[UIButton alloc]initWithFrame:CGRectMake(150, 12, ScreenWidth,60)];
                [suobtn addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
                [view2 addSubview:suobtn];
                NSString *s = [NSString stringWithFormat:@"%@ ( %@ )",   [[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"memberName"]   ,[[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"phone"]];
                UIFont *font = [UIFont systemFontOfSize:titleNamefot];
                CGSize size = CGSizeMake(320, 2000);
                CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
                huiyuanname=[[UILabel alloc]initWithFrame:CGRectMake(15, 15, labelsize.width+3, titleNamefot)];
                huiyuanname.text=[NSString stringWithFormat:@"%@ ( %@ )",[[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"memberName"]   ,   [[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"phone"]];
                huiyuanname.textColor=[UIColor blackColor];
                huiyuanname.font=[UIFont systemFontOfSize:titleNamefot];
                [view2 addSubview:huiyuanname];
                
                UIImageView*Seximage=[[UIImageView alloc]initWithFrame:CGRectMake(huiyuanname.right, 14, 20, 20)];
                if (![[[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"sex"] isEqual:[NSNull null]]) {
                    
                    if ([[[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"sex"]isEqualToString:@"男"]) {
                        Seximage.image=[UIImage imageNamed:@"nan"];
                        
                        
                    }else{
                        Seximage.image=[UIImage imageNamed:@"nv"];
                    }
                    
                    
                }else{
                        Seximage.image=[UIImage imageNamed:@"nv"];
                    
                    
                }
                
                [view2 addSubview:Seximage];
                
                commdity.memberId=[[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"memberId"];
                
                
                
                huiyuanname=[[UILabel alloc]initWithFrame:CGRectMake(15, 30, ScreenWidth-30, 30)];
                huiyuanname.text=[NSString stringWithFormat:@"%@",   [[severDataDict.dataDict objectForKey:@"member"] objectForKey:@"address"]];
                huiyuanname.textColor=shenhuicolor;
                huiyuanname.numberOfLines=2;
                huiyuanname.font=[UIFont systemFontOfSize:contenfot];
                [view2 addSubview:huiyuanname];
                
                UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, view2.bottom, ScreenWidth, 0.35)];
                line1.backgroundColor=qianhuicolor;
                [MYmainScroll addSubview:line1];
                UILabel *line18=[[UILabel alloc] initWithFrame:CGRectMake(0, view2.bottom+10-0.35, ScreenWidth, 0.35)];
                line18.backgroundColor=qianhuicolor;
                [MYmainScroll addSubview:line18];
                
                
                view3=[[UIView alloc]initWithFrame:CGRectMake(0, view2.bottom+10, ScreenWidth, 45)];
                view3.backgroundColor=[UIColor whiteColor];
                [MYmainScroll addSubview:view3];
                
                
                UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
                shangpingxinxi.text=@"商品信息";
                shangpingxinxi.textColor=[UIColor blackColor];
                shangpingxinxi.font=[UIFont systemFontOfSize:15];
                [view3 addSubview:shangpingxinxi];
                
                
                
                
                
    
    UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(15, 45-0.35, ScreenWidth-30, 0.35)];
    lineLabel1.backgroundColor=qianhuicolor;
    [view3 addSubview:lineLabel1];
    
    
    MYmainScroll.frame=CGRectMake(0, 0, ScreenWidth, view3.bottom);
    [MYmainScroll setContentSize:CGSizeMake(ScreenWidth, view3.bottom)];
    
    
    table.tableHeaderView=MYmainScroll;
    
    
    arrrss=[severDataDict.dataDict objectForKey:@"orderItem"];
    
    
    
    
    
    NSLog(@"11111%@",arrrss);
    if (arrrss.count>0) {
        
        
        
        
        for (NSDictionary* dicc in arrrss )
        {
            [selectduoshaoArray addObject:[dicc valueForKey:@"dealPrice"]];
            [selectimageArray addObject:[dicc valueForKey:@"headImageFull"]];
            [orderItemIds addObject:[dicc valueForKey:@"thisItemId"]];
            [selectName addObject:[dicc valueForKey:@"itemName"]];
            [selectshuliangArray addObject:[dicc valueForKey:@"thisQty"]];
            
            NSString*str=[NSString stringWithFormat:@"%d",  [[dicc valueForKey:@"quantity"]intValue]-[[dicc valueForKey:@"refundQuantity"]intValue]] ;
            
            
            [keyiquantity addObject:str];

            [quantity addObject:[dicc valueForKey:@"thisQty"]];
            [selectFeatureCodeArray addObject:[dicc valueForKey:@"itemCode"]];
            [selectguigeArray addObject:[dicc valueForKey:@"specName"]];
        }
        
        
    }
    
    
    [table reloadData];
    
   
    
    footview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,600)];
    footview.backgroundColor=zuiqianhuicolor;
    
    
    view4=[[UIView alloc]initWithFrame:CGRectMake(0, 10, ScreenWidth, 90)];
    view4.backgroundColor=[UIColor whiteColor];
    [footview addSubview:view4];
    UILabel *lineL=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
    lineL.backgroundColor=qianhuicolor;
    [view4 addSubview:lineL];
    
    
    UILabel*shoukuanxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
    shoukuanxinxi.text=@"服务登记";
    shoukuanxinxi.textColor=shenhuicolor;
    shoukuanxinxi.font=[UIFont systemFontOfSize:15];
    [view4 addSubview:shoukuanxinxi];
    
    
    UILabel*shihui=[[UILabel alloc]initWithFrame:CGRectMake(15, 30, 33, 45)];
    shihui.text=@"来源";
    shihui.textColor=shenhuicolor;
    shihui.font=[UIFont systemFontOfSize:contenfot];
    [view4 addSubview:shihui];
    
    UILabel*shihuiduoshao=[[UILabel alloc]initWithFrame:CGRectMake(shihui.right, 30, 250, 45)];
    shihuiduoshao.text=[NSString stringWithFormat:@"%@ %@",   [[severDataDict.dataDict objectForKey:@"predict"] objectForKey:@"predictName"],   [[severDataDict.dataDict objectForKey:@"predict"] objectForKey:@"predictDate"]];
    shihuiduoshao.textColor=shenhuicolor;
    shihuiduoshao.font=[UIFont systemFontOfSize:contenfot];
    [view4 addSubview:shihuiduoshao];
    
    NSNumber*Total = [[severDataDict.dataDict objectForKey:@"predict"] objectForKey:@"predictMoney"];
    totalMoney = [[severDataDict.dataDict objectForKey:@"predict"] objectForKey:@"predictMoney"];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:Total.doubleValue]];
    
    NSString *ss =[NSString stringWithFormat:@"服务金额 ¥%@",   formattedNumberString];
    
    UIFont *font1ss = [UIFont systemFontOfSize:contenfot];
    CGSize size1ss = CGSizeMake(ScreenWidth-60, 2000);
    CGSize labelsize1ss = [ss sizeWithFont:font1ss constrainedToSize:size1ss lineBreakMode:NSLineBreakByCharWrapping];
    
    UILabel*shihuiduoshao1=[[UILabel alloc]initWithFrame:CGRectMake(15, 50, labelsize1ss.width+5, 45)];
    shihuiduoshao1.text=[NSString stringWithFormat:@"服务金额 ¥%@",   formattedNumberString];
    shihuiduoshao1.textColor=shenhuicolor;
    shihuiduoshao1.font=[UIFont systemFontOfSize:contenfot];
    [view4 addSubview:shihuiduoshao1];
    
    
    UILabel*sat=[[UILabel alloc]initWithFrame:CGRectMake(shihuiduoshao1.right, 50, 160, 45)];
    sat.text=@"未支付";
    sat.textColor=hongsecolor;
    sat.font=[UIFont systemFontOfSize:contenfot];
    [view4 addSubview:sat];
    
    
    UILabel *line13=[[UILabel alloc] initWithFrame:CGRectMake(0, view4.bottom, ScreenWidth, 0.35)];
    line13.backgroundColor=qianhuicolor;
    [footview addSubview:line13];
    UILabel *line181=[[UILabel alloc] initWithFrame:CGRectMake(0, view4.bottom+10-0.35, ScreenWidth, 0.35)];
    line181.backgroundColor=qianhuicolor;
    [footview addSubview:line181];
    
    zhangkai=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-90, 50, 80, 45)];
    [zhangkai setTitle:@"展开更多" forState:UIControlStateNormal];
    [zhangkai setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    [zhangkai addTarget:self action:@selector(zhankai:) forControlEvents:UIControlEventTouchUpInside];
    zhangkai.titleLabel.font=[UIFont systemFontOfSize:12];
    zhangkai.titleLabel.textAlignment=UIControlContentHorizontalAlignmentRight;
    [view4 addSubview:zhangkai];
    
    commdity.Memo=[NSString stringWithFormat:@"%@",[[severDataDict.dataDict objectForKey:@"predict"] objectForKey:@"predictDesc"]];
    
    
    diview=[[UIView alloc]initWithFrame:CGRectMake(0, view4.bottom, ScreenWidth, 60)];
    diview.backgroundColor=[UIColor whiteColor];
    [footview addSubview:diview];
    UIView*diview1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
    diview1.backgroundColor=zuiqianhuicolor;
    [diview addSubview:diview1];
    
    UILabel *lineLabel11111=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
    lineLabel11111.backgroundColor=qianhuicolor;
    [diview addSubview:lineLabel11111];
    UILabel *lineLabel11=[[UILabel alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 0.35)];
    lineLabel11.backgroundColor=qianhuicolor;
    [diview addSubview:lineLabel11];
    UILabel *lineLabel119=[[UILabel alloc] initWithFrame:CGRectMake(0, 60, ScreenWidth, 0.35)];
    lineLabel119.backgroundColor=qianhuicolor;
    [diview addSubview:lineLabel119];
    
    UILabel* jine=[[UILabel alloc]initWithFrame:CGRectMake(15, 10, 80, 50)];
    jine.text=[NSString stringWithFormat:@"服务金额"];
    jine.textColor=shenhuicolor;
    jine.font=[UIFont systemFontOfSize:15];
    [diview addSubview:jine];
    myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:daxiao];
    [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    
    xianjinTextFied=[[UITextField alloc]initWithFrame:CGRectMake(170/2,10, ScreenWidth*300/750,50)];
    xianjinTextFied.borderStyle = UITextBorderStyleNone;
    xianjinTextFied.keyboardType = UIKeyboardTypeDecimalPad;
    xianjinTextFied.font = [UIFont systemFontOfSize: 14];
    xianjinTextFied.textColor=[UIColor blackColor];
    xianjinTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
    xianjinTextFied.tag=6;
    xianjinTextFied.text=[NSString stringWithFormat:@"%@",[[severDataDict.dataDict objectForKey:@"service"] objectForKey:@"totalMoney"]];
    xianjinTextFied.placeholder = @"请输入服务金额"; //默认显示的字
    xianjinTextFied.delegate = self;
    [xianjinTextFied setUserInteractionEnabled:YES];
    xianjinTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
    [diview addSubview:xianjinTextFied];
    xianjinTextFied.inputAccessoryView=myToolBar;
    
    
    
    
    footerview=[[UIView alloc]initWithFrame:CGRectMake(0, diview.bottom+10, ScreenWidth, 110)];
    footerview.backgroundColor=[UIColor whiteColor];
    [footview addSubview:footerview];
    
    tv=[[UITextView alloc]init];
    tv.frame=CGRectMake(15, 10, ScreenWidth-30, 90);
    tv.backgroundColor = [UIColor whiteColor];//设置它的背景颜色/Users/jiezsoft/Desktop/
    tv.scrollEnabled = YES;//是否可以拖动
    tv.delegate=self;
    //                tv.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高
    tv.font = [UIFont fontWithName:@"Arial" size:15.0];//设置字体名字和字体大小
    tv.layer.borderWidth =0;
    CGColorSpaceRef registedSpace11 = CGColorSpaceCreateDeviceRGB();
    CGColorRef tureBTncolorref111 = CGColorCreate(registedSpace11,(CGFloat[]){ 0, 0, 0, 0.3 });
    //                tv.keyboardType = UIKeyboardTypePhonePad;
    [tv.layer setBorderColor:tureBTncolorref111];//边框颜色
    tv.layer.cornerRadius =0;
    [footerview addSubview:tv];
    imagess=[[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 18, 16)];
    imagess.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
    [tv addSubview:imagess];
    label=[[UILabel alloc]init];
    label.frame =CGRectMake(28, 5, ScreenWidth-60, 15);
    label.text = @"描述";
    label.textColor=zuiqianhuicolor;
    label.numberOfLines=0;
    label.font=[UIFont systemFontOfSize:15];
    label.enabled = NO;//lable必须设置为不可用
    label.backgroundColor = [UIColor clearColor];
    [tv addSubview:label];
    
    tv.inputAccessoryView = myToolBar;
    table.tableFooterView= footview;
  
    UIButton*buyBtn2=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth, 48)];
    [buyBtn2 setTitle:@"售后确认" forState:UIControlStateNormal];
    buyBtn2.backgroundColor=luseColor;
    [buyBtn2 addTarget:self action:@selector(ture:) forControlEvents:UIControlEventTouchUpInside];
    
    [buyBtn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:buyBtn2];
    
    
}else{
    [Global hideProgressHUDInternal:self.view];
    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
    [Global showTextHudSub:requestResultStr view:self.view];
}

}
else
{
    [Global hideProgressHUDInternal:self.view];
    NSLog(@"aaaaaaaa%@",severDataDict.dataDict);
    [Global showTextHudSub:@"连接失败" view:self.view];
}

}];


}

-(void)xiangqing:(UIButton*)sender{
    
    
    huiyuanDetailsViewController *detailViewController = [[huiyuanDetailsViewController alloc] init];
    
    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
    
}
- (void)ture:(UIButton *)button{
    
    if ([xianjinTextFied.text length] <1)
    {
        [self showAlertMessage:@"请输入服务金额！"];
    }
    else{
        
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        NSString* Token = [user objectForKey:@"tokenId"];
        if (Token ==nil) {
            Token=@"dd";
        }
        
        NSMutableDictionary *params = [NSMutableDictionary new];
        [params setValue:Token forKey:@"tokenId"];
        [params setValue:commdity.orderId forKey:@"serviceId"];
        [params setValue:xianjinTextFied.text forKey:@"confirmMoney"];
        [params setValue:tv.text forKey:@"confirmDesc"];
        
        
        NSMutableArray *mDocumentLine=[NSMutableArray array];
        
        
        for (int i=0; i<orderItemIds.count; i++) {
            
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            NSString *itemIdstr = [orderItemIds objectAtIndex:i];
            NSString *quantitystr =[selectshuliangArray objectAtIndex:i];
            
            
            
            [dic setValue:quantitystr forKey:@"quantity"];
            [dic setValue:itemIdstr forKey:@"itemId"];
            [mDocumentLine addObject:dic];
            
            
        }
        [params setValue:mDocumentLine  forKey:@"serviceItems"];
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
        
        
        [HttpRequest requestData:@"Business/Service/Confirm" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {    NSLog(@"33333333====%@",severDataDict.dataDict);
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    if (xianjinTextFied.text.intValue==0) {
                        [self.navigationController popViewControllerAnimated:YES];
                        
                   
                    
                    }else{
                        

           
                        commdity.sat=@"fuwushouyin";
                        
                        commdity.how=xianjinTextFied.text;
                        ToResiduePayViewController* Login=[[ToResiduePayViewController alloc]init];
                        
                        [self.navigationController pushViewController:Login animated:YES];

         
                        
                    }
                    
                }else{
                    
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    // [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
                
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
            
        }];
        
    }
    
    
    
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    
    
    return [arrrss count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    ConfirmCell* cell = (ConfirmCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"ConfirmCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(0,0, 8, 13);
    [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
    
    
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    cell.saveAccount=YES;
    
    
    [cell.imageview.layer setCornerRadius:5.0];
    [cell.imageview.layer setBorderWidth:0.3];
    [cell.imageview.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
    [cell.imageview.layer setBorderColor:colorref2];//边框颜色
    [cell.imageview setImageWithURL:[NSURL URLWithString:[selectimageArray objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@""]];
    
    
    cell.xuanzeimage.image=[UIImage imageNamed:@"gous"];
    cell.xuanzeimage.userInteractionEnabled=NO;
    cell.shopCartId=[[arrrss  objectAtIndex:indexPath.row]valueForKey:@"id"];
    
    cell.title.text =[NSString stringWithFormat:@"%@%@",[selectFeatureCodeArray objectAtIndex:indexPath.row],[selectName objectAtIndex:indexPath.row]];
    
    cell.title.font=[UIFont systemFontOfSize:15];
    cell.title.textColor=[UIColor blackColor];
    
    cell.title.numberOfLines=2;
    
    if ([[selectguigeArray objectAtIndex:indexPath.row]isEqualToString:@""]) {
        cell.guige.text =[NSString stringWithFormat:@"%@",@" "];
    }else{
        cell.guige.text =[NSString stringWithFormat:@"%@",[selectguigeArray objectAtIndex:indexPath.row]];}
    
    cell.guige.font=[UIFont systemFontOfSize:14];
    cell.guige.textColor=zhonghuiColor;
    
    
    
    cell.shuliang.text =[NSString stringWithFormat:@"%.f",  [[selectshuliangArray objectAtIndex:indexPath.row]floatValue]];
    cell.shuliang.font=[UIFont systemFontOfSize:14];
    
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",[selectduoshaoArray objectAtIndex:indexPath.row]];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    cell.jiage.text =[NSString stringWithFormat:@"￥%@",  formattedNumberString];
    cell.jiage.font=[UIFont systemFontOfSize:17];
    cell.jiage.textColor=hongsecolor;
    NSMutableAttributedString *AttributedSt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@",  formattedNumberString]];
    
    [AttributedSt addAttribute:NSFontAttributeName
     
                         value:[UIFont systemFontOfSize:14]
     
                         range:NSMakeRange(0, 1)];
    
    [AttributedSt addAttribute:NSForegroundColorAttributeName
     
                         value:hongsecolor
     
                         range:NSMakeRange(0, 1)];
    
    
    cell.jiage.attributedText = AttributedSt;
    //        cell.xiugaijiage=[NSString stringWithFormat:@"%@",[dealPrice objectAtIndex:indexPath.row]];
    [cell.xiugai setBackgroundImage :[UIImage imageNamed:@"bianji.png"] forState:UIControlStateNormal];
    [cell.xiugai addTarget:self action:@selector(xiugai:) forControlEvents:UIControlEventTouchUpInside];
    
    
    if (selectimageArray.count !=indexPath.row+1) {
        UILabel *lineLabel31=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
        lineLabel31.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel31];
        
    }
    
    if (selectimageArray.count ==indexPath.row+1) {
        UILabel *lineLabel31=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
        lineLabel31.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel31];
        
    }
    
    
    
    
    
    
    return cell;
}
//修改按钮
-(void)xiugai:(UIButton*)sender{
    
    [xiugaiview removeFromSuperview];
    UIButton* button=(UIButton * )sender;
    ConfirmCell* cell=(ConfirmCell* )button.superview.superview;
    cell.saveAccount=NO;
    
    
    toumingtu=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    toumingtu.backgroundColor=[UIColor clearColor];
    
    // 手势
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [toumingtu addGestureRecognizer:singleFingerOne];
    [footview addSubview:toumingtu];
    
    
    xiugaiview=[[UIButton alloc]initWithFrame:CGRectMake(cell.imageview.right+10, 0, ScreenWidth, 120)];
    xiugaiview.backgroundColor=zuiqianhuicolor;
    [cell addSubview:xiugaiview];
    
    UILabel* cjjlabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 30, 50, 16)];
    cjjlabel.text=@"成交价";
    cjjlabel.textColor=shenhuicolor;
    cjjlabel.font=[UIFont systemFontOfSize:16];
    [xiugaiview addSubview:cjjlabel];
    
    
    jiageTextFied=[[UITextField alloc]initWithFrame:CGRectMake(cjjlabel.right+10,  30, 150, 18)];
    
    jiageTextFied.keyboardType = UIKeyboardTypeDecimalPad;
    jiageTextFied.borderStyle = UITextBorderStyleNone;
    jiageTextFied.font = [UIFont systemFontOfSize: contenfot];
    jiageTextFied.textColor=[UIColor blackColor];
    jiageTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
    jiageTextFied.tag=sender.tag;
    jiageTextFied.text=[NSString stringWithFormat:@"%@",[selectduoshaoArray objectAtIndex:sender.tag]];
    [jiageTextFied setUserInteractionEnabled:NO];
    jiageTextFied.font=[UIFont systemFontOfSize:18];
    jiageTextFied.delegate = self;
    jiageTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
    [xiugaiview addSubview:jiageTextFied];
    
    
    UILabel* shulianglabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 75, 50, 16)];
    shulianglabel.text=@"数量";
    shulianglabel.textColor=shenhuicolor;
    shulianglabel.font=[UIFont systemFontOfSize:15];
    [xiugaiview addSubview:shulianglabel];
    
    
    UIImageView*shuimageview=[[UIImageView alloc]initWithFrame:CGRectMake(shulianglabel.right+10, 70, 110, 30)];
    shuimageview .image=[UIImage imageNamed:@"tianjias"];
    [xiugaiview addSubview:shuimageview];
    
    shu=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 110, 30)];
    shu.text=[NSString stringWithFormat:@"%@",  cell.shuliang.text];
    shu.textColor=[UIColor blackColor];
    shu.center=shuimageview.center;
    shu.textAlignment=NSTextAlignmentCenter;
    shu.font=[UIFont systemFontOfSize:15];
    [xiugaiview addSubview:shu];
    
    UIButton*jian=[[UIButton alloc]initWithFrame:CGRectMake(shulianglabel.right+10, 70, 30, 30)];
    [jian addTarget:self action:@selector(jian:) forControlEvents:UIControlEventTouchUpInside];
    jian.tag=sender.tag;
    [xiugaiview addSubview:jian];
    commdity.status=[NSString stringWithFormat:@"%ld",sender.tag];
    UIButton*jia=[[UIButton alloc]initWithFrame:CGRectMake(shulianglabel.right+10+90,70, 30, 30)];
    jia.tag=sender.tag;
    [jia addTarget:self action:@selector(jia:) forControlEvents:UIControlEventTouchUpInside];
    [xiugaiview addSubview:jia];
    //    [self heji];
}
-(void)jia:(UIButton*)sender{
    
    UIButton* button=(UIButton * )sender;
    ConfirmCell* cell=(ConfirmCell* )button.superview.superview;
    
    if (cell.shuliang.text .intValue==[[keyiquantity objectAtIndex:sender.tag]intValue]) {
        [self showAlertMessage:@"服务的数量不能超过购买时候的数量！"];
    }else{
        
        int d;
        d=shu.text.intValue;
        d++;
        NSLog(@"---------%ld",sender.tag);
        
        
        NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:quantity];
        [mutableArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
        quantity = mutableArray;
        cell.shuliang.text=[NSString stringWithFormat:@"%d", d];
        shu.text=[NSString stringWithFormat:@"%d", d];
         [selectshuliangArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
    }
    
    
    
}

-(void)jian:(UIButton*)sender{
    
    UIButton* button=(UIButton * )sender;
    ConfirmCell* cell=(ConfirmCell* )button.superview.superview;
    
    if ([cell.shuliang.text isEqualToString:@"1"]) {
        [self showAlertMessage:@"数量不能为 0 件！"];
        
        
    }else{
        
        int d;
        d= shu.text.intValue;
        d--;
        NSLog(@"---------%ld",sender.tag);
        
        NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:quantity];
        [mutableArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
        quantity = mutableArray;//now the array has been "updated"
        cell.shuliang.text=[NSString stringWithFormat:@"%d", d];
        shu.text=[NSString stringWithFormat:@"%d", d];
        
        
         [selectshuliangArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
        
    }
    
    
}


- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return  120;
}




- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [toumingtu removeFromSuperview];
    [xiugaiview removeFromSuperview];
    
    
}









-(void)zhankai:(UIButton*)sender
{
    
    [zhangkai removeFromSuperview];
    [beizhuView removeFromSuperview];
    
    beizhuView=[[UIView alloc]initWithFrame:CGRectMake(0, view4.bottom, ScreenWidth, 180*ScreenHeight/1334)];
    beizhuView.backgroundColor=[UIColor whiteColor];
    [footview addSubview:beizhuView];
    
    UILabel*beizhu=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth*70/750, 45)];
    beizhu.text=@"说明";
    beizhu.font= [UIFont systemFontOfSize:contenfot];
    [beizhu setTextColor:qianheicolor];
    [beizhuView addSubview:beizhu];
    
    if ([commdity.Memo length]>1) {
        
        
        NSString *s1 =[NSString stringWithFormat:@"%@", commdity.Memo];
        UIFont *font1 = [UIFont systemFontOfSize:contenfot];
        CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
        CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
        
        UILabel*beizhu1=[[UILabel alloc]initWithFrame:CGRectMake(15, beizhu.bottom, ScreenWidth-40, labelsize1.height+30)];
        beizhu1.text=s1;
        beizhu1.numberOfLines=0;
        beizhu1.font= [UIFont systemFontOfSize:contenfot];
        [beizhu1 setTextColor:shenhuicolor];
        [beizhuView addSubview:beizhu1];
        beizhuView.frame=CGRectMake(0, view4.bottom, ScreenWidth, beizhu1.bottom+20);
        
        
    }else{
        beizhuView.frame=CGRectMake(0, view4.bottom, ScreenWidth, beizhu.bottom+20);
        
        [footview addSubview:beizhuView];
        
    }
    
    
    diview.frame=CGRectMake(0, beizhuView.bottom, ScreenWidth, 60);
    footerview.frame=CGRectMake(0, diview.bottom +10, ScreenWidth, 110);
    
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    
    
    
    if (textField.tag == 6)
    { [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        table .frame =CGRectMake(0, -250, ScreenWidth, ScreenHeight);
        [UIView commitAnimations];
        
        
    }
    
    
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    table .frame =CGRectMake(0, -250, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    
    
    
    return self;
}


//回收键盘
-(void)OnTapDone{
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    table .frame =CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    [toumingtu removeFromSuperview];
    [xiugaiview removeFromSuperview];
    [xianjinTextFied resignFirstResponder];
    [tv resignFirstResponder];
    
    
}
-(void)closeKeyBoad
{
    
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    table .frame =CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    [toumingtu removeFromSuperview];
    [xiugaiview removeFromSuperview];
    
    [xianjinTextFied resignFirstResponder];
    [tv resignFirstResponder];
}



- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    
    //    if (textField.tag == 5)
    //    {
    
    if (range.location >= 9){
        return NO;
    }
    if ([textField.text rangeOfString:@"."].location==NSNotFound) {
        isHaveDian=NO;
    }
    if ([string length]>0)
    {
        unichar single=[string characterAtIndex:0];//当前输入的字符
        if ((single >='0' && single<='9') || single=='.')//数据格式正确
        {
            //首字母不能为0和小数点
            if([textField.text length]==0){
                if(single == '.'){
                    
                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    return NO;
                    
                }
                //                    if (single == '0') {
                //                        // [self alertView:@"亲，第一个数字不能为0"];
                //                        [textField.text stringByReplacingCharactersInRange:range withString:@""];
                //                        return NO;
                //
                //                    }
            }
            if (single=='.')
            {
                if(!isHaveDian)//text中还没有小数点
                {
                    isHaveDian=YES;
                    return YES;
                }else
                {
                    //[self alertView:@"亲，您已经输入过小数点了"];
                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    return NO;
                }
            }
            else
            {
                if (isHaveDian)//存在小数点
                {
                    //判断小数点的位数
                    NSRange ran=[textField.text rangeOfString:@"."];
                    int tt=range.location-ran.location;
                    if (tt <= 2){
                        return YES;
                    }else{
                        //[self alertView:@"亲，您最多输入两位小数"];
                        return NO;
                    }
                }
                else
                {
                    return YES;
                }
            }
        }else{//输入的数据格式不正确
            //[self alertView:@"亲，您输入的格式不正确"];
            [textField.text stringByReplacingCharactersInRange:range withString:@""];
            return NO;
        }
    }
    
    
    
    
    
    
    return YES;
    
    
    
    
    
}

- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
-(void)textViewDidChange:(UITextView *)textView
{
    //self.examineText =  textView.text;
    
    
    if (textView.text.length == 0) {
        [imagess removeFromSuperview];
        
        imagess=[[UIImageView alloc]initWithFrame:CGRectMake(15, 5, 51/3, 51/3)];
        imagess.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
        [tv addSubview:imagess];
        label.text = @"描述";
        
    }else{
        [imagess removeFromSuperview];
        label.text = @"";
    }
}



@end
